package com.sto.stoapp.entity;

import android.os.Environment;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class AviationToPieceLogEntity {
	public String cause = "";
	public String code = "";
	public String emp_code = "";
	SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public String site_code = "";
	public String time = this.sDateFormat.format(new Date());

	public String toString() {
		return "[" + this.code + "|" + this.time + "|" + this.cause + "|"
				+ this.site_code + "|" + this.emp_code + "]";
	}

	public void writeLog() {
		String status = Environment.getExternalStorageState();
		if (!Environment.MEDIA_MOUNTED.equals(status))
			return;
		try {
			File localFile1 = Environment.getExternalStorageDirectory();
			String str1 = new SimpleDateFormat("yyyyMM").format(new Date());
			File localFile2 = new File(localFile1.getAbsolutePath()
					+ File.separator + "sto" + File.separator + "log"
					+ File.separator + str1);
			if (!localFile2.exists()) {
				localFile2.mkdir();
			}
			String str2 = new SimpleDateFormat("yyyyMMdd").format(new Date());
			File localFile3 = new File(localFile1.getAbsolutePath()
					+ File.separator + "sto" + File.separator + "log"
					+ File.separator + str1 + File.separator
					+ "AviationToPieceLog" + str2 + ".txt");
			if (!localFile3.exists()) {
				localFile3.createNewFile();
			}
			FileOutputStream localFileOutputStream = new FileOutputStream(
					localFile3, true);
			if (this != null) {
				localFileOutputStream.write(toString().getBytes());
				localFileOutputStream.write("\r\n".getBytes());
				localFileOutputStream.write("\r\n".getBytes());
			}
			localFileOutputStream.close();
		} catch (Exception localException) {
			localException.getStackTrace();
		}
	}
}
